<?php
/**
 *
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

?>
<!DOCTYPE html>
<html>
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		Tsunami: 
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('icon');

		echo $this->Html->css(array('cake.generic', 'bootstrap.min', 'bootstrap-theme.min'));
		echo $this->Html->script(array('jquery-1.11.0.min','bootstrap.min'));

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
	?>
</head>
<body>
	<div id="container">
		<div id="header" >
			<?php echo 	$this->Html->image('tsunami.jpg', array('alt' => 'Tsunami Project', 'border' => '0')); ?>

			<h1>Engenharia Hídrica UFPEL</h1>
			

			<div class="menu-login">
				<?php if ($userLogged != null): ?>
					Seja Bem-Vindo: <?php echo $userLogged['nome']; ?> | <?php echo $this->Html->link('Logout', array('controller' => 'users', 'action' => 'logout', 'admin' => false));?>
				<?php else: ?>
					<?php echo $this->Html->link('Login', array('controller' => 'users', 'action' => 'login'));?>
				<?php endif; ?>
			</div>
			<div class="menu-nav">
				<ul class="nav nav-tabs">
					<li class="<?php echo ($this->params['controller'] == 'mapa')?'active':''?>">
						<?php echo $this->Html->link('Home', '/');?>
					</li>
					<?php if ($hasPermission['pesquisador']): ?>
						<li class="<?php echo (strpos($this->params['controller'], 'leituras')  !== false)?'active':''?>">
							<a class="dropdown-toggle" data-toggle="dropdown" href="#"> Leituras <span class="caret"></span> </a>
			    			<ul class="dropdown-menu">
			    				<?php foreach ($estacoesMenu as $estacao): ?>
			    					<li>
			    						<?php echo $this->Html->link($estacao['Estacao']['nome'], array('controller' => 'estacoes', 'action' => 'leitura', 'pesquisador' => true, $estacao['Estacao']['id']));?>
			    					</li>
			    				<?php endforeach; ?>
			    			</ul>
			    		</li>

			    		<li class="<?php echo ($this->params['controller'] == 'estacoes')?'active':''?>">
							<?php echo $this->Html->link('Estações', array('controller' => 'estacoes', 'action' => 'index', 'pesquisador' => true));?>
						</li>
					<?php endif; ?>

					<?php if ($hasPermission['admin']): ?>
						<li class="<?php echo ($this->params['controller'] == 'users')?'active':''?>">
							<?php echo $this->Html->link('Usuários', array('controller' => 'users', 'action' => 'index', 'admin' => true));?>
						</li>
					<?php endif; ?>

					<li class="<?php echo ($this->params['controller'] == 'pages' && @$this->params['pass'][0] == 'about')?'active':''?>">
						<?php echo $this->Html->link('Sobre o Projeto', '/about');?>
					</li>
				</ul>
			</div>
		</div>
		<div id="content">

			<?php echo $this->Session->flash(); ?>

			<?php echo $this->fetch('content'); ?>
		</div>
		<div id="footer">
			<?php echo $this->Html->link(
					$this->Html->image('cake.power.gif', array('alt' => 'CakePHP', 'border' => '0')),
					'http://www.cakephp.org/',
					array('target' => '_blank', 'escape' => false)
				);
			?>
		</div>
	</div>

	<script type="text/javascript">
		$('.dropdown-toggle').dropdown();
	</script>
</body>
</html>
